package casbinApi

import (
	"github.com/Sir-yuChen/funAnalyse/model"
	"github.com/Sir-yuChen/funAnalyse/model/common/response"
	"github.com/Sir-yuChen/funAnalyse/model/request"
	"github.com/Sir-yuChen/funAnalyse/utils"
	"github.com/gin-gonic/gin"
)

type StockCasbinRoleRelationUserController struct{}

// AssigningRole 给用户分配角色
// @Summary AssigningRole
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/assigningRole [POST]
func (b *StockCasbinRoleRelationUserController) AssigningRole(c *gin.Context) {
	var req request.AssigningRoleRequest
	if err := c.ShouldBindJSON(&req); err != nil {
		utils.ErrValidatorResp(err, "AssigningRole", req, c)
		return
	}
	apiReturn := stockCasbinRoleRelationUserService.AssigningRole(&req, c)
	response.WithApiReturn(apiReturn, c)
	return
}

// GetStockCasbinRoleRelationUser 多条件查询
// @Summary stockCasbinRoleRelationUser get
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleRelationUserModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/getCasbinRoleRelationUser [GET]
func (b *StockCasbinRoleRelationUserController) GetStockCasbinRoleRelationUser(c *gin.Context) {
	var req model.StockCasbinRoleRelationUserModel
	if err := c.ShouldBindJSON(&req); err != nil {
		utils.ErrValidatorResp(err, "GetStockCasbinRoleRelationUser", req, c)
		return
	}
	apiReturn := stockCasbinRoleRelationUserService.GetStockCasbinRoleRelationUser(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// InsertStockCasbinRoleRelationUser
// @Summary stockCasbinRoleRelationUser insert
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleRelationUserModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/insertCasbinRoleRelationUser [POST]
func (b *StockCasbinRoleRelationUserController) InsertStockCasbinRoleRelationUser(c *gin.Context) {
	var req model.StockCasbinRoleRelationUserModel
	if err := c.ShouldBindJSON(&req); err != nil {
		utils.ErrValidatorResp(err, "InsertStockCasbinRoleRelationUser", req, c)
		return
	}
	apiReturn := stockCasbinRoleRelationUserService.InsertStockCasbinRoleRelationUser(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// UpdateStockCasbinRoleRelationUser
// @Summary stockCasbinRoleRelationUser update
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleRelationUserModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/updateCasbinRoleRelationUser [POST]
func (b *StockCasbinRoleRelationUserController) UpdateStockCasbinRoleRelationUser(c *gin.Context) {
	var req model.StockCasbinRoleRelationUserModel
	if err := c.ShouldBindJSON(&req); err != nil {
		utils.ErrValidatorResp(err, "UpdateStockCasbinRoleRelationUser", req, c)
		return
	}
	apiReturn := stockCasbinRoleRelationUserService.UpdateStockCasbinRoleRelationUser(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// DelStockCasbinRoleRelationUser
// @Summary stockCasbinRoleRelationUser del
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleRelationUserModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/delCasbinRoleRelationUser [Get]
func (b *StockCasbinRoleRelationUserController) DelStockCasbinRoleRelationUser(c *gin.Context) {
	var req model.StockCasbinRoleRelationUserModel
	if err := c.ShouldBindJSON(&req); err != nil {
		utils.ErrValidatorResp(err, "DelStockCasbinRoleRelationUser", req, c)
		return
	}
	apiReturn := stockCasbinRoleRelationUserService.DelStockCasbinRoleRelationUser(&req)
	response.WithApiReturn(apiReturn, c)
	return
}
